package com.binary.coder.gift.core.domain.ai.factory;

import com.binary.coder.gift.core.common.constant.AIModelType;
import com.binary.coder.gift.core.domain.ai.AiService;
import com.binary.coder.gift.core.domain.ai.impl.HunyuanClient;
import com.binary.coder.gift.core.domain.ai.impl.XingHuoClient;
import com.google.common.collect.Maps;
import com.tencentcloudapi.common.Credential;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author atao
 * @version 1.0.0
 * @ClassName AiFactory.java
 * @Description 工厂类
 * @createTime 2024年06月25日 14:57:00
 */
@Component
public class AiFactory implements ApplicationContextAware {

    private static final Map<String, AiService> AI_FACTORY = Maps.newHashMap();

    private String secretId = "AKIDmiwAW3a7azOydSOUgylju9a1bvFj9Swn";
    private String secretKey = "HV484OKIsSfH1nf8apADFOqN6PnlsfSm";


    private String xinghuo_secretId = "ZTcxZGIwYTM3MjhhN2Q5YjdjZTA0ODg5";
    private String xingghuo_secretKey = "fbf11ce13d2c0ca512717296ca4ac362";

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        AI_FACTORY.putIfAbsent(AIModelType.HUNYUAN.getTypeCode(),new HunyuanClient(new Credential(secretId,secretKey),null));
        AI_FACTORY.putIfAbsent(AIModelType.XINGHUO.getTypeCode(), new XingHuoClient(xinghuo_secretId,xingghuo_secretKey));
    }

    public AiService getAiServiceByTypeCode(String typeCode) {
        return AI_FACTORY.get(typeCode);
    }


}

